﻿
var fnCustomAdd = function () {
    var name = getPar(decodeURI(location.href), "name");
    var solutionId = getPar(decodeURI(location.href), "id");
    const_EditEntity = "salSalaryItem";
    var pagetitle = "新增薪资项——薪资方案(" + name + ")";
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&flag=set&solutionId="+solutionId+"&entity=" + const_EditEntity));
    parent.NeedRefreshPage = this;
}

var fnCustomEdit = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    var name = getPar(decodeURI(location.href), "name");
    var solutionId = getPar(decodeURI(location.href), "id");
    const_EditEntity = "salSalaryItem";
    var pagetitle = "修改薪资项—" + record.getData("ItemName") + "－薪资方案(" + name + ")";
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&flag=set&solutionId=" + solutionId + "&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID)));
    parent.NeedRefreshPage = this;
}

//删除第一步
var fnCustomDelete = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    var id = record.getData(const_entityID);
    //第一步先删除该薪资方案对应的薪资项目
    YAHOO.util.Connect.asyncRequest('POST', "../EHR/hrSalaryAjax.aspx?flag=deleteSalaryItemOfSolution&id=" + id+"&r="+Math.random(), {
        success: function (res) {
            try {
                var str = res.responseText;
                if (str == "0") {
                    YAHOO.example.container.dialog3.show();
                }
                else {
                    alert("薪资方案对应的薪资项删除失败！");
                    return;
                }
            }
            catch (e) {
                alert("删除失败：" + e.Message);
                return;
            }
            finally {
            }
        },
        failure: function (error) {
            alert("数据错误：" + error.statusText);
            return;
        }
    }, null);
}

var fnCustomDeleteData = function () {
    YAHOO.example.container.dialog3.hide();
    window.alert("数据删除成功！");
    fnReload();
}